/**
 * Copyright (c) 2011-2015, Mobangjack 莫帮杰 (mobangjack@foxmail.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.twogen.im;

import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * @author 帮杰
 */
public class Test {

	public static void main(String[] args) {
		File imageFile = new File("lena_noisy.jpg");
		BufferedImage originalImage = ImageIOHelper.getImage(imageFile);
		PixelImage pixelImage = new PixelImage(originalImage);
		ImageFilter imageFilter = new ImageFilter();
		imageFilter.median(pixelImage);
		Image filteredImage = pixelImage.toImage();
		JFrame jFrame = new JFrame("MedianFilter - 莫帮杰 & 周建丰");
		jFrame.setLayout(new FlowLayout());
		jFrame.setBounds(400, 300, 400, 600);
		jFrame.setVisible(false);
		ImageIcon icon1 = new ImageIcon(originalImage);
		ImageIcon icon2 = new ImageIcon(filteredImage);
		JLabel jLabel1 = new JLabel("Original Image", icon1, 0);
		JLabel jLabel2 = new JLabel("Filtered Image", icon2, 0);
		jFrame.add(jLabel1);
		jFrame.add(jLabel2);
		jFrame.setVisible(true);
	}

}
